package com.gdit.revenue.service.Impl;

import com.gdit.revenue.base.result.Results;
import com.gdit.revenue.dao.UserDao;
import com.gdit.revenue.model.User;
import com.gdit.revenue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    @Override
    public Results getAllUsers(int offset, int limit) {
        //获取到记录对象的总行数
        int count = userDao.count();
        return Results.success(count,userDao.getAllUsers(offset,limit));
    }

    @Override
    public Results delete(int userid) {
        return Results.success(userDao.delete(userid));
    }

    @Override
    public void addUser(User user) {
        userDao.insert(user);
    }

    @Override
    public Results updateUser(User user) {
        return Results.success(userDao.update(user));
    }
}
